package com.hxzy.es.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 商品spu表的数据ES索引
 *
 * @author tonneyyy
 */
@Getter
@Setter
@Document(indexName = "spu_goods",createIndex = true,type = "docs")
public class EsSpuGoods {

    @Id

    private String id; // spuId

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String all;

    @Field(type = FieldType.Keyword)
    private String name;

    @Field(type = FieldType.Keyword)
    private String caption;// 副标题

    @Field(type = FieldType.Long)
    private Integer brandId;// 品牌id

    /**
     * 品牌名称
     */
    @Field(type = FieldType.Keyword, index = true)
    private String brandName;


    @Field(type = FieldType.Long)
    private Integer category1Id;// 1级分类id

    /**
     * 分类1
     */
    @Field(type = FieldType.Keyword, index = true)
    private String category1Name;

    @Field(type = FieldType.Long)
    private Integer category2Id;// 2级分类id

    /**
     * 分类2
     */
    @Field(type = FieldType.Keyword, index = true)
    private String category2Name;


    @Field(type = FieldType.Long)
    private Integer category3Id;// 3级分类id

    /**
     * 分类3
     */
    @Field(type = FieldType.Keyword, index = true)
    private String category3Name;


    @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
    @Field(name = "create_time",type = FieldType.Date, format = DateFormat.custom,
            pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSX")
    private Date createTime;// 创建时间

    private List<Integer> price;// 价格(分)

    @Field(type = FieldType.Keyword, index = false)
    private String skus;// sku信息的json结构


    private Map<String, Object> specs;// 可搜索的规格参数，key是参数名，值是参数值

}
